<template>
	<div>
		<div id="top2">
			缺陷分配
		</div>
		<div class="one2">	
			<div>缺陷名称：{{recordBug.bugName}}</div>
		</div>
		<div class="one2">
			<div>缺陷分类：{{recordBug.bugClassify}}</div>
		</div>
		<div class="one2">
			<div>缺陷程度：{{recordBug.degree}}</div>
		</div>
		<div class="one2">
			<div>缺陷优先级：{{recordBug.bugPriority}}</div>
		</div>
		<div class="one2">
			<div>预计完成时常：{{recordBug.ptime}}</div>
		</div>
		<div class="one2">
			<div>缺陷详情：{{recordBug.bugDetail}}</div>
		</div>
		<div class="one2">
			指派给：
			<select v-model="dealName">
				<option v-for="name in nameList">{{name}}</option>
			</select>
		</div>
		<div class="one2">
			<input type="button" value="保存" @click="insertDealTime()"/>
		</div>
	</div>
</template>

<script>
	import $ from "jquery"
	export default {
	  name: "DistributionBug",
	  data:function() {
		  return {
			  dealName:"",
			  recordBug:{},
			  nameList:[],
			  dealTime:{
				  bugId:"",
				  ptime:"",
				  dealbyName:"",
				  recordState:"待处理"
			  }
		  }
	  },
	  created:function(){
		  this.select();
		  this.selectName();
	  },
	  methods: {
		  select:function(){
			  var ts = this;
			  var bugId=this.$route.query.bugId;
			  $.ajax({
				  url:"http://localhost/bugDistribution/queryBug",
				  type:"get",
				  data:{"id":bugId},
				  headers:{"token":localStorage.getItem("token")},
				  success:function(data){
					  ts.recordBug = data.obj;
				  }
				  
			  })
		  },
		  selectName:function(){
		  			  var ts = this;
		  			  $.ajax({
		  				  url:"http://localhost/bugDistribution/queryUser",
		  				  type:"get",
		  				  data:{"id":3},
						  headers:{"token":localStorage.getItem("token")},
		  				  success:function(data){
		  					  ts.nameList = data.list;
		  				  }
		  				  
		  			  })
		  },
		  insertDealTime:function(){
			  var ts = this;
			  this.dealTime.bugId=this.recordBug.bugId;
			  this.dealTime.ptime=this.recordBug.ptime;
			  this.dealTime.dealbyName=this.dealName;
			  var bugId=this.$route.query.bugId;
			  $.ajax({
			  	url:"http://localhost/bugDistribution",
			  	type:"post",
			  	data:ts.dealTime,
				headers:{"token":localStorage.getItem("token")},
			  	success:function(data){
					$.ajax({
						url:"http://localhost/bugList/update",
						type:"post",
						data:{"dostate":"待处理","bugId":bugId},
						headers:{"token":localStorage.getItem("token")},
						success:function(data){
						}  	
					})
			  	}  				  
			  });
			  
			  $("#lk").attr("style","display: none")
			  this.$router.push("/QueryBugByState")
		  }
	  }
	}
</script>

<style>
	#top2{
		height: 25px;
		width: 100%;
		float: left;
		background-color: #cecece;
		text-align: center;
		line-height: 30px;
	}
	.one2{
		height: 50px;
		width: 100%;
		float: left;
		background-color: #e1e1e1;
		text-align: center;
		line-height: 50px;
	}
</style>
